package com.situ.mall.common.controller;

import com.situ.mall.common.service.IAttachmentService;
import com.situ.mall.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author yangkx
 * @create 2023-09-13-15:55
 */
//附件上传控制器
@Controller
@RequestMapping("/attachment")
public class AttachmentController {

    @Autowired
    private IAttachmentService attachmentService;

    //单附件上传（首页图）把上传文件保存到本地，同时返回访问路径
    @PostMapping("/uploadOne")
    @ResponseBody
    public ResultVO uploadOne(MultipartFile file) {
        return attachmentService.uploadOne(file);
    }

    //多附件上传（详图）保存至数据库
    @PostMapping("/upload")
    @ResponseBody
    public ResultVO upload(MultipartFile file) {
        return attachmentService.upload(file);
    }

}
